package com.example.abe.diandi.trends.fragment;

import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.OnClick;
import com.example.abe.diandi.R;

import example.abe.com.framework.viewinject.ViewInjectUtils;

public class TakePhotoModeDialogFragment extends DialogFragment {

    static TakePhotoModeDialogFragment newInstance() {
        TakePhotoModeDialogFragment f = new TakePhotoModeDialogFragment();
        return f;
    }

    private OnSelectedTakePhotoListener mListener;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_take_photo_mode_dialog, container, false);
        ViewInjectUtils.inject(this, v);
        return v;
    }

    /**
     * 选择照片监听
     * @param listener 监听
     */
    public void setSelectedTakePhotoListener(OnSelectedTakePhotoListener listener){
        mListener = listener;
    }

    @OnClick({R.id.frag_take_photo_mode_tv_select_photo, R.id.frag_take_photo_mode_tv_take_photo})
    protected void onTakePhotoClick(View v){
        Mode mode = Mode.SELECT_PHOTO;
        switch (v.getId()){
            case R.id.frag_take_photo_mode_tv_select_photo:
                mode = Mode.SELECT_PHOTO;
                break;
            case R.id.frag_take_photo_mode_tv_take_photo:
                mode = Mode.TAKE_PHOTO;
                break;
        }
        if (mListener != null) {
            mListener.onTakePhotoModeSelected(mode);
        }
    }

    public interface OnSelectedTakePhotoListener {
        /**
         * 删除此图文模块
         */
        void onTakePhotoModeSelected(Mode mode);
    }

    public enum Mode{
        /**
         * 从相册中选取
         */
        SELECT_PHOTO,

        /**
         * 拍照选取
         */
        TAKE_PHOTO,
    }
}